package org.dtrd.modules.record.entity.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.common.util.DateUtils;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.record.entity.po.DtrdEntRdSigninSuggest;

import java.util.Date;

/**
 * 打卡项目:1 血糖；2血压；3运动；4用药；5 饮食；6 体重；7腰围；8尿酮；9 胰岛素；10睡眠；11营养素
 */
@ApiModel("打卡建议数据对象")
@Data
public class SigninSuggestBean {

    @ApiModelProperty("建议记录id, 更新时传入")
    private Integer dataId;

    @ApiModelProperty(value = "患者id", required = true)
    private Integer patientId;

    @ApiModelProperty(value = "建议类型", required = true)
    private Integer signinType;
    @ApiModelProperty(value = "建议类型文本")
    private String signinTypeText;

    @ApiModelProperty(value = "记录时间")
    private String recordDate;

    @ApiModelProperty(value = "建议内容", required = true)
    private String suggestContent;

    @ApiModelProperty("图标")
    private String icon;

    @ApiModelProperty(value = "创建日期", required = true)
    private Date creatTime;

    @ApiModelProperty(value = "创建人", required = true)
    private String createBy;

    public SigninSuggestBean parseFromPO(DtrdEntRdSigninSuggest po) {
        this.setDataId(po.getDataId());
        this.setPatientId(po.getPatientId());
        this.setSigninType(po.getSigninType());
        Constant.SuggestType suggestType = Constant.SuggestType.valueOf(po.getSigninType());
        this.setSigninTypeText(suggestType.getName());
        // this.setSigninTypeText(po.getSigninTypeText());
        if (po.getRecordTime() != null) {
            this.setRecordDate(DateUtils.formatDate(po.getRecordTime(), DateUtils.date_sdf.get().toPattern()));
        }
        switch (suggestType) {
            case MEDICAL:
                icon = "https://imgs.dtx-tech.com/checkin/pill.png";
                break;
            case DIET:
                icon = "https://imgs.dtx-tech.com/checkin/dinner.png";
                break;
            case SPORT:
                icon = "https://images-gz.oss-cn-guangzhou.aliyuncs.com/upload/sport_icon_1648791175567.png";
                break;
            case INSULIN:
                icon = "https://imgs.dtx-tech.com/checkin/pin.png";
                break;
        }
        this.setSuggestContent(po.getSuggestContent());
        this.setCreatTime(po.getCreateTime());
        this.setCreateBy(po.getCreatBy());
        return this;
    }

}
